from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt # 局部禁用csrf
from django.views.generic import View
from django.conf import settings

class LoginRequiredMixin(object):
    """设置登陆检测Mixin"""

    @classmethod
    def as_view(cls, **initkwargs): # 参数直接as_view拷贝源码的参数即可
        # 调用父类的as_view
        view = super(LoginRequiredMixin, cls).as_view(**initkwargs) # 继承父类的as_view方法
        return login_required(view) # 在返回view的使用，先调用login_required进行包括
